import fetch from '../../utils/services'
const app = getApp()

Page({
  data: {
    actionSheetHidden: true,
    phone: ''
  },
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '我的'
    })
    fetch.post('/user/details', {}).then(data => {
      console.log(data)
      var phoneNumber = data.phoneNum;
      if (phoneNumber.length >= 11) {
        phoneNumber = phoneNumber.substring(0,3) + '****' + phoneNumber.substring(7,11)
      }
      this.setData({ 
        phone: phoneNumber
        })
    })
  },
  customerService: function() {
    const system =  wx.getSystemInfoSync()
    const itemList = ['呼叫(10086)']
    if (/android/i.test(system.platform)) {
      itemList.push('取消')
    }
    wx.showActionSheet({
      itemList: itemList,
      success (res) {
        if (res.tapIndex === 0) {
          wx.makePhoneCall({
            phoneNumber: '10086',
          })
        }
      },
      fail (res) {
        console.log(res.errMsg)
      }
    })
    // this.setData({ actionSheetHidden: false, phone: 10086 })
  }
})
